package com.xgkj.diyiketang.task;

import com.alibaba.fastjson.JSONObject;
import com.xgkj.diyiketang.http.CouponHttpRequest;
import com.xgkj.diyiketang.http.CouponHttpResponse;
import com.xgkj.diyiketang.http.engine.CouponHttpBaseTask;
import com.xgkj.diyiketang.http.engine.TaskResultCode;
import com.xgkj.diyiketang.util.LogUtils;

/**
 * Created by Tao on 2017/6/13.
 */
public class GetUsemingeTask extends CouponHttpBaseTask {
    private String mQuotaId;
    private String mObjectId;
    public GetUsemingeTask(String quotaId,String objectId){
        super();
        mQuotaId = quotaId;
        mObjectId = objectId;
    }
    @Override
    protected void processResponseData(CouponHttpResponse response) {
        JSONObject jsonObject = response.getBody();
        String isUse = jsonObject.getString("isUse");
//        GifInfo info = JSON.parseObject(jsonObject.toString(),GifInfo.class);
        notifyTaskCompleted(TaskResultCode.SUCCESS,isUse);
    }

    @Override
    protected void prepareRequest() {
        super.prepareRequest();
        if (mPhase == TASK_PHASE_INIT) {
            CouponHttpRequest request = new CouponHttpRequest(RequestType.GETUSE_MINGE_REQUEST);
            JSONObject json = new JSONObject();
            json.put("objectId", mObjectId);
            json.put("quotaId",mQuotaId);
            request.setData(json.toString());
            request.setApiNo(ApiNo.USE_MINGE);
            addRequest(request);
        }
    }
}
